<template>
<!-- 上传组件 -->
<div id="app">
      <el-upload
      action="http://linweiqin.cn:8001/v1/addimg/avatar"
      :show-file-list="false"
      :on-success="handleAvatarSuccess"
      :before-upload="beforeAvatarUpload"
    >
      <img v-if="imageUrl" :src="imageUrl" alt="" />
      <i v-else class="el-icon-plus avatar-uploader-icon"></i>
    </el-upload>
</div>
</template>

<script>

export default {
  name: 'App',
  components: {
    
  },
  data:function(){
    return{
      imageUrl:''
   
    }
  },
  methods:{
  // 文件上传成功后
       handleAvatarSuccess: function (res) {
      let imageUrl = "http://linweiqin.cn:8001/img/" + res.image_path;
      this.imageUrl = imageUrl;
    },
  }
}
</script>

<style>
*{
  margin:0;
  padding: 0;
  box-sizing: border-box;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
  border: 1px solid #ddd;
}
img{
  width: 178px;
  height: 178px;
}
</style>
